package com.econ.powercloud.ems.service.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.econ.powercloud.ems.dal.entity.EmsModuleConfig;
import com.econ.powercloud.ems.dal.entity.EmsStrategyConfig;
import com.econ.powercloud.ems.dal.mapper.EmsStrategyConfigMapper;
import org.apache.kafka.common.protocol.types.Field;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @ Description:
 * @ Author：hgp
 * @ Create:2023-02-08-16:18
 */
@Repository
public class EmsStrategyConfigDAO extends ServiceImpl<EmsStrategyConfigMapper, EmsStrategyConfig> {

    public List<EmsStrategyConfig> selectByCondition(Integer display, List<String> strategyIdList) {
        LambdaQueryWrapper<EmsStrategyConfig> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(display != null, EmsStrategyConfig::getDisplay, display);
        wrapper.in(CollectionUtils.isNotEmpty(strategyIdList),EmsStrategyConfig::getStrategyId, strategyIdList);
        return this.baseMapper.selectList(wrapper);
    }

    public EmsStrategyConfig selectByStrategyId(String strategyId){
        LambdaQueryWrapper<EmsStrategyConfig> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(StringUtils.isNotBlank(strategyId),EmsStrategyConfig::getStrategyId,strategyId);
        wrapper.last("limit 1");
        return this.baseMapper.selectOne(wrapper);
    }
}
